using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace Cripta
{
    public partial class FrmCripta : Form
    {
        string passPhrase = "Pas5pr@se";        // can be any string
        string saltValue = "s@1tValue";        // can be any string
        string hashAlgorithm = "SHA1";             // can be "MD5"
        int passwordIterations = 2;                  // can be any number
        string initVector = "@1B2c3D4e5F6g7H8"; // must be 16 bytes
        int keySize = 256;                // can be 192 or 128

        public FrmCripta()
        {
            InitializeComponent();
                        
        }

        private void btnMeteCripta_Click(object sender, EventArgs e)
        {
            try { txtEncriptado.Text = Sepultador.meterCripta(txtAEncriptar.Text, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize); }
            catch
            {
                FrmError error = new FrmError("encripta");
                error.ShowDialog();
            }
        }

        private void btnSacaCripta_Click(object sender, EventArgs e)
        {
            try { txtAEncriptar.Text = Sepultador.sacarCripta(txtEncriptado.Text, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize); }
            catch
            {
                FrmError error = new FrmError("desencripta");
                error.ShowDialog();
            }
        }

        private void btnBorrar_Click(object sender, EventArgs e)
        {
            txtAEncriptar.Text = "";            
        }

        private void btnBorrar1_Click(object sender, EventArgs e)
        {
            txtEncriptado.Text = "";
        }

        private void btnPegar_Click(object sender, EventArgs e)
        {
            txtAEncriptar.Text = Clipboard.GetText();
        }

        private void btnCopiar_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(txtEncriptado.Text);
        }

       
    }
}